<?php
/**
 * Created by PhpStorm.
 * User: zlkmu
 * Date: 2017/10/4
 * Time: 17:02
 * 表示房间的类，是所有各种房间的基类
 */
    class Room{
        public $roomID;                 //房间ID
        public $roomType;               //房间类型，实际为游戏类型
        public $playerList=array();     //玩家队列，存储的为用户的UID

        public $isBegin;                //是否开始
        public $totalCount;             //房间总盘数
        public $currentRound;           //当前盘数
        public $isUsed = false;         //代表房间是否被使用


        public $dissolveCount = 0;      //同意解散房间人数数量
        public $refuseDissolve = 0;     //拒绝解散房间人数数量
        public $isDissolve=false;       //是否解散房间

        public $operationTime=0;//本次操作时间

        /**
         * @return
         */
        public function getRoomID()
        {
            return $this->roomID;
        }

        /**
         * @param $roomID
         */
        public function setRoomID($roomID)
        {
            $this->roomID = $roomID;
        }


        /**
         * @return
         */
        public function getRoomType()
        {
            return $this->roomType;
        }

        /**
         * @param $roomType
         */
        public function setRoomType($roomType)
        {
            $this->roomType = $roomType;
        }

        /**
         * @return mixed
         */
        public function getPlayerList()
        {
            return $this->playerList;
        }

        /**
         * 获取房间人数
         */
        public function getPlayerNum(){
            return count($this->playerList);
        }

        /**
         * 添加玩家到房间
         * @param $userUid
         */
        public function addPlayerToList($userUid)
        {

            for($i = 0; $i < count($this->playerList); $i++){
                if($this->playerList[$i] == $userUid)
                    return;
            }
            array_push($this->playerList,$userUid);
        }

        /**
         * 从房间移除玩家
         * @param $userUid
         */
        public function delPlayerToList($userUid)
        {
            for($i = 0; $i < count($this->playerList); $i++){
                if($this->playerList[$i] == $userUid){
                    array_splice($this->playerList, $i, 1);
                    break;
                }
            }
        }

    }

?>